package com.chuangsi.project.admin.service.impl;



import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.chuangsi.common.utils.MyStringUtils;
import com.chuangsi.project.admin.domain.ModelTable;
import com.chuangsi.project.admin.dto.admin.model.ReqModelPageDto;
import com.chuangsi.project.admin.dto.admin.model.ReqModelUpdateDto;
import com.chuangsi.project.admin.dto.admin.model.ResModelPageDto;
import com.chuangsi.project.admin.dto.common.SelectDto;
import com.chuangsi.project.admin.mapper.ModelTableMapper;
import com.chuangsi.project.admin.service.ModelService;
import org.springframework.stereotype.Service;
import springfox.documentation.swagger2.mappers.ModelMapper;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 型号表 服务实现类
 * </p>
 *
 * @author 
 * @since 2023-03-23
 */
@Service
public class ModelServiceImpl extends ServiceImpl<ModelTableMapper, ModelTable> implements ModelService {

    @Override
    public List<ResModelPageDto> modelPage(ReqModelPageDto req) {
        return baseMapper.modelPage(req);
    }

    @Override
    public Map<String, String> getModelMap() {
        return list().stream().collect(Collectors.toMap(ModelTable::getModelId,ModelTable::getModelName));
    }

    @Override
    public List<SelectDto> modelSelect() {
        return list().stream().map(x->new SelectDto(x.getModelId(),x.getModelName())).collect(Collectors.toList());
    }
}
